
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Ansible 学习笔记 · 日常学习笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-page-footer-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-advanced-emoji/emoji-website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="Ansible常用模板.html" />
    
    
    <link rel="prev" href="Ansible必知单词.html" />
    

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"buttons":[{"user":"Xiechengqi","repo":"LearningNotes","type":"star","size":"small","count":true}]};
    </script>

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../网络学习资源整理/">
            
                <a href="../网络学习资源整理/">
            
                    
                    网络学习资源整理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../网络学习资源整理/技术学习.html">
            
                <a href="../网络学习资源整理/技术学习.html">
            
                    
                    技术学习
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../网络学习资源整理/运维博客.html">
            
                <a href="../网络学习资源整理/运维博客.html">
            
                    
                    运维博客
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../网络学习资源整理/工具.html">
            
                <a href="../网络学习资源整理/工具.html">
            
                    
                    工具
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../网络学习资源整理/静态博客模板.html">
            
                <a href="../网络学习资源整理/静态博客模板.html">
            
                    
                    静态博客模板
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../网络学习资源整理/静态网站pages服务.html">
            
                <a href="../网络学习资源整理/静态网站pages服务.html">
            
                    
                    静态网站pages服务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../网络学习资源整理/静态pages的CI和CD.html">
            
                <a href="../网络学习资源整理/静态pages的CI和CD.html">
            
                    
                    静态pages的CI和CD
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../网络学习资源整理/Hugo学习.html">
            
                <a href="../网络学习资源整理/Hugo学习.html">
            
                    
                    Hugo学习
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../心灵鸡汤/">
            
                <a href="../心灵鸡汤/">
            
                    
                    心灵鸡汤
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../心灵鸡汤/心灵鸡汤.html">
            
                <a href="../心灵鸡汤/心灵鸡汤.html">
            
                    
                    语录
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../Linux/">
            
                <a href="../Linux/">
            
                    
                    Linux
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../Linux/Linux常用命令.html">
            
                <a href="../Linux/Linux常用命令.html">
            
                    
                    Linux常用命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../Linux/Linux小知识.html">
            
                <a href="../Linux/Linux小知识.html">
            
                    
                    平时 linux 遇到的问题解决办法和扩展小知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../Linux/Linux性能相关常用命令.html">
            
                <a href="../Linux/Linux性能相关常用命令.html">
            
                    
                    Linux性能相关常用命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../Linux/Linux各种安装下载慢解决方法.html">
            
                <a href="../Linux/Linux各种安装下载慢解决方法.html">
            
                    
                    Linux各种安装下载慢解决方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../Linux/APT-剖析详解.html">
            
                <a href="../Linux/APT-剖析详解.html">
            
                    
                    APT 原理剖析、详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../Linux/Linux主机、虚拟机和docker网络配置.html">
            
                <a href="../Linux/Linux主机、虚拟机和docker网络配置.html">
            
                    
                    Linux 主机、虚拟机和docker网络配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../Linux/Linux文件系统学习.html">
            
                <a href="../Linux/Linux文件系统学习.html">
            
                    
                    Linux文件系统学习
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../Linux/Linux用户和用户组管理.html">
            
                <a href="../Linux/Linux用户和用户组管理.html">
            
                    
                    Linux用户和用户组管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="../Linux/Linux用户增删改等学习.html">
            
                <a href="../Linux/Linux用户增删改等学习.html">
            
                    
                    Linux用户增删改等学习.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="../Linux/Linux程序存放目录.html">
            
                <a href="../Linux/Linux程序存放目录.html">
            
                    
                    Linux程序存放目录.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.11" data-path="../Linux/Linux编译安装软件包详解.html">
            
                <a href="../Linux/Linux编译安装软件包详解.html">
            
                    
                    Linux C/C++ 软件包编译、安装原理详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.12" data-path="../Linux/SSH详解.html">
            
                <a href="../Linux/SSH详解.html">
            
                    
                    SSH 详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.13" data-path="../Linux/Tomcat和Ngnix和Apache.html">
            
                <a href="../Linux/Tomcat和Ngnix和Apache.html">
            
                    
                    Tomcat和Ngnix和Apache.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.14" data-path="../Linux/UbuntuSoftwareInstall.html">
            
                <a href="../Linux/UbuntuSoftwareInstall.html">
            
                    
                    Ubuntu 软件包安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.15" data-path="../Linux/YAML-配置文件语言.html">
            
                <a href="../Linux/YAML-配置文件语言.html">
            
                    
                    YAML 配置文件语言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.16" data-path="../Linux/bin目录详解.html">
            
                <a href="../Linux/bin目录详解.html">
            
                    
                    bin目录详解.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.17" data-path="../Linux/ffmpeg详解.html">
            
                <a href="../Linux/ffmpeg详解.html">
            
                    
                    ffmpeg学习
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.18" data-path="../Linux/trans命令.html">
            
                <a href="../Linux/trans命令.html">
            
                    
                    trans命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.19" data-path="../Linux/yum和rpm.html">
            
                <a href="../Linux/yum和rpm.html">
            
                    
                    Yum 和 RPM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.20" data-path="../Linux/从BashShell启动“窥探”Linux环境变量相关文件.html">
            
                <a href="../Linux/从BashShell启动“窥探”Linux环境变量相关文件.html">
            
                    
                    Linux环境变量详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.21" data-path="../Linux/新创建主机常用初始化配置.html">
            
                <a href="../Linux/新创建主机常用初始化配置.html">
            
                    
                    新建主机常用初始化配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.22" data-path="../Linux/正则表达式学习.html">
            
                <a href="../Linux/正则表达式学习.html">
            
                    
                    正则表达式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.23" data-path="../Linux/通过Linux开机启动项展开学习.html">
            
                <a href="../Linux/通过Linux开机启动项展开学习.html">
            
                    
                    Linux开机启动项学习
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.24" data-path="../Linux/防火墙学习.html">
            
                <a href="../Linux/防火墙学习.html">
            
                    
                    防火墙学习笔记
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../Python/">
            
                <a href="../Python/">
            
                    
                    Python
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../Python/BeautifulSoup.md">
            
                <span>
            
                    
                    Python3 BeautifulSoup 学习记录
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../Python/Django.html">
            
                <a href="../Python/Django.html">
            
                    
                    Python Django 学习笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../Python/IPython使用技巧.html">
            
                <a href="../Python/IPython使用技巧.html">
            
                    
                    IPython 使用技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../Python/Numpy.html">
            
                <a href="../Python/Numpy.html">
            
                    
                    Python Numpy 学习
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../Python/Python小知识.html">
            
                <a href="../Python/Python小知识.html">
            
                    
                    Python 学习遇到的问题解决或扩展小知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../Python/Python模块管理总结.html">
            
                <a href="../Python/Python模块管理总结.html">
            
                    
                    Python 模块管理总结
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="../Python/flask学习.md">
            
                <span>
            
                    
                    Flask 学习
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="../Python/matplotlib.html">
            
                <a href="../Python/matplotlib.html">
            
                    
                    matplotlib.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9" data-path="../Python/re正则表达式.html">
            
                <a href="../Python/re正则表达式.html">
            
                    
                    re正则表达式.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.10" data-path="../Python/图形界面学习.html">
            
                <a href="../Python/图形界面学习.html">
            
                    
                    图形界面学习.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.11" data-path="../Python/常用图像库学习.html">
            
                <a href="../Python/常用图像库学习.html">
            
                    
                    Python3 常用图像库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.12" data-path="../Python/进阶学习.html">
            
                <a href="../Python/进阶学习.html">
            
                    
                    Python3 进阶学习笔记
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../Shell/">
            
                <a href="../Shell/">
            
                    
                    Shell
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../Shell/shell小知识.html">
            
                <a href="../Shell/shell小知识.html">
            
                    
                    Shell小知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../Shell/Shell奇淫技巧.html">
            
                <a href="../Shell/Shell奇淫技巧.html">
            
                    
                    Shell奇淫技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../Shell/Linux文本操作三大利器-grep、sed、awk.html">
            
                <a href="../Shell/Linux文本操作三大利器-grep、sed、awk.html">
            
                    
                    grep、sed、awk 详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../Shell/Shell文本处理常用工具补遗.html">
            
                <a href="../Shell/Shell文本处理常用工具补遗.html">
            
                    
                    Shell文本处理常用工具补遗
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../Shell/句子解析.html">
            
                <a href="../Shell/句子解析.html">
            
                    
                    句子解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../Shell/识别是否是root用户.html">
            
                <a href="../Shell/识别是否是root用户.html">
            
                    
                    识别是否是root用户
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../Shell/识别系统.html">
            
                <a href="../Shell/识别系统.html">
            
                    
                    识别系统
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../Vim/">
            
                <a href="../Vim/">
            
                    
                    Vim
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../Vim/Vim小知识.html">
            
                <a href="../Vim/Vim小知识.html">
            
                    
                    Vim小知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../Vim/Vim编辑器再学习.html">
            
                <a href="../Vim/Vim编辑器再学习.html">
            
                    
                    Vim编辑器再学习
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../Vim/VimScript学习笔记.html">
            
                <a href="../Vim/VimScript学习笔记.html">
            
                    
                    VimScript 学习笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../Vim/YouCompleteMe安装.html">
            
                <a href="../Vim/YouCompleteMe安装.html">
            
                    
                    YouCompleteMe安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../Vim/vimrc示例1.html">
            
                <a href="../Vim/vimrc示例1.html">
            
                    
                    vimrc示例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="../Vim/vimrc备份.html">
            
                <a href="../Vim/vimrc备份.html">
            
                    
                    vimrc备份
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" data-path="../Vim/Tmux快捷键.html">
            
                <a href="../Vim/Tmux快捷键.html">
            
                    
                    Tmux快捷键
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="./">
            
                <a href="./">
            
                    
                    Ansible
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="术语表.html">
            
                <a href="术语表.html">
            
                    
                    术语表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="Ansible必知单词.html">
            
                <a href="Ansible必知单词.html">
            
                    
                    Ansible 常用单词
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.8.3" data-path="Ansible学习.html">
            
                <a href="Ansible学习.html">
            
                    
                    Ansible 学习笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="Ansible常用模板.html">
            
                <a href="Ansible常用模板.html">
            
                    
                    Ansible常用模板.md
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../Docker/">
            
                <a href="../Docker/">
            
                    
                    Docker
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../Docker/Docker基础学习.html">
            
                <a href="../Docker/Docker基础学习.html">
            
                    
                    Docker 基础学习笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../Docker/Docker小知识.html">
            
                <a href="../Docker/Docker小知识.html">
            
                    
                    Docker 小知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../Docker/Docker必知单词.html">
            
                <a href="../Docker/Docker必知单词.html">
            
                    
                    Docker 学习中的单词
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../Git/">
            
                <a href="../Git/">
            
                    
                    Git
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../Git/git学习.html">
            
                <a href="../Git/git学习.html">
            
                    
                    Git 学习笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../Git/git小技巧.html">
            
                <a href="../Git/git小技巧.html">
            
                    
                    Git 小技巧
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../Zabbix/">
            
                <a href="../Zabbix/">
            
                    
                    Zabbix
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../Zabbix/Docker安装配置Zabbix.html">
            
                <a href="../Zabbix/Docker安装配置Zabbix.html">
            
                    
                    Docker 安装配置 Zabbix
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../Zabbix/术语单词.html">
            
                <a href="../Zabbix/术语单词.html">
            
                    
                    Zabbix 中常用单词
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../Zabbix/重置密码.html">
            
                <a href="../Zabbix/重置密码.html">
            
                    
                    重置 Zabbix 账户密码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../KVM/">
            
                <a href="../KVM/">
            
                    
                    KVM
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../KVM/安装配置.html">
            
                <a href="../KVM/安装配置.html">
            
                    
                    常用命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../KVM/虚拟机网络配置.html">
            
                <a href="../KVM/虚拟机网络配置.html">
            
                    
                    Bridged 桥接模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../Mysql/">
            
                <a href="../Mysql/">
            
                    
                    Mysql
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../Mysql/Ubuntu安装Navicat.html">
            
                <a href="../Mysql/Ubuntu安装Navicat.html">
            
                    
                    Ubuntu 安装及配置 Navicat
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../Mysql/忘记root密码.html">
            
                <a href="../Mysql/忘记root密码.html">
            
                    
                    如何替换已忘记的 root 密码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../Nginx/">
            
                <a href="../Nginx/">
            
                    
                    Nginx
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.14.1" data-path="../Nginx/Nginx学习笔记.html">
            
                <a href="../Nginx/Nginx学习笔记.html">
            
                    
                    Nginx 学习
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../NoClass/">
            
                <a href="../NoClass/">
            
                    
                    闲知
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.1" data-path="../NoClass/容易读错的IT术语.html">
            
                <a href="../NoClass/容易读错的IT术语.html">
            
                    
                    容易读错的IT术语
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2" data-path="../NoClass/Linux-electron-tutorial.html">
            
                <a href="../NoClass/Linux-electron-tutorial.html">
            
                    
                    Linux electron 学习记录
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3" data-path="../NoClass/MarkdownSkills.html">
            
                <a href="../NoClass/MarkdownSkills.html">
            
                    
                    记录 Markdown 的各种小技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4" data-path="../NoClass/RaspeberryPi.html">
            
                <a href="../NoClass/RaspeberryPi.html">
            
                    
                    使用树莓派 3B 遇到的问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.5" data-path="../NoClass/华为国产手机芯片SoC.html">
            
                <a href="../NoClass/华为国产手机芯片SoC.html">
            
                    
                    华为国产手机芯片SoC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.6" data-path="../NoClass/图片格式详解及其对比.html">
            
                <a href="../NoClass/图片格式详解及其对比.html">
            
                    
                    图片格式详解及其对比
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.7" data-path="../NoClass/计算机小知识.html">
            
                <a href="../NoClass/计算机小知识.html">
            
                    
                    记录一些计算机的小知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.8" data-path="../NoClass/诗词.html">
            
                <a href="../NoClass/诗词.html">
            
                    
                    诗词
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="../OS/">
            
                <a href="../OS/">
            
                    
                    OS
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.16.1" data-path="../OS/学习笔记.html">
            
                <a href="../OS/学习笔记.html">
            
                    
                    操作系统学习笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16.2" data-path="../OS/术语单词.html">
            
                <a href="../OS/术语单词.html">
            
                    
                    OS 专业词语解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16.3" data-path="../OS/SoCCPU.html">
            
                <a href="../OS/SoCCPU.html">
            
                    
                    SoC 与 CPU
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="../Tomcat/">
            
                <a href="../Tomcat/">
            
                    
                    Tomcat
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.17.1" data-path="../Tomcat/Tomcat 学习.html">
            
                <a href="../Tomcat/Tomcat 学习.html">
            
                    
                    Tomcat 学习
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.2" data-path="../Tomcat/Tomcat学习.html">
            
                <a href="../Tomcat/Tomcat学习.html">
            
                    
                    Tomcat 学习
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="../VPS/">
            
                <a href="../VPS/">
            
                    
                    VPS
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.18.1" data-path="../VPS/AWS_lightsail.html">
            
                <a href="../VPS/AWS_lightsail.html">
            
                    
                    AWS LightSail
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.2" data-path="../VPS/GCP_VM实例创建和基本配置.html">
            
                <a href="../VPS/GCP_VM实例创建和基本配置.html">
            
                    
                    GCP VM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.3" data-path="../VPS/ECS和VPS等等.html">
            
                <a href="../VPS/ECS和VPS等等.html">
            
                    
                    ECS和VPS
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="../ComputerComposition/">
            
                <a href="../ComputerComposition/">
            
                    
                    ComputerComposition
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.19.1" data-path="../ComputerComposition/学习笔记.html">
            
                <a href="../ComputerComposition/学习笔记.html">
            
                    
                    计算机组成原理学习笔记
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="../ComputerNetwork/">
            
                <a href="../ComputerNetwork/">
            
                    
                    ComputerNetwork
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.20.1" data-path="../ComputerNetwork/ProWords.html">
            
                <a href="../ComputerNetwork/ProWords.html">
            
                    
                    术语单词
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20.2" data-path="../ComputerNetwork/学习笔记.html">
            
                <a href="../ComputerNetwork/学习笔记.html">
            
                    
                    计算机网络学习笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20.3" data-path="../ComputerNetwork/小知识.html">
            
                <a href="../ComputerNetwork/小知识.html">
            
                    
                    学习计算机网络中的小知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20.4" data-path="../NoClass/浏览器架构简析.md">
            
                <span>
            
                    
                    浏览器架构简析
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="../毕业论文/">
            
                <a href="../毕业论文/">
            
                    
                    毕业论文
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.21.1" data-path="../毕业论文/开题报告.html">
            
                <a href="../毕业论文/开题报告.html">
            
                    
                    开题报告
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Ansible 学习笔记</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="ansible-&#x5B66;&#x4E60;&#x7B14;&#x8BB0;"><a name="ansible-&#x5B66;&#x4E60;&#x7B14;&#x8BB0;" class="plugin-anchor" href="#ansible-&#x5B66;&#x4E60;&#x7B14;&#x8BB0;"><i class="fa fa-link" aria-hidden="true"></i></a>Ansible &#x5B66;&#x4E60;&#x7B14;&#x8BB0;</h1>
<h2 id="&#x76EE;&#x5F55;"><a name="&#x76EE;&#x5F55;" class="plugin-anchor" href="#&#x76EE;&#x5F55;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x76EE;&#x5F55;</h2>
<ul>
<li><p><strong><a href="#ansible&#x67B6;&#x6784;">Ansible &#x67B6;&#x6784;</a></strong></p>
</li>
<li><p><strong><a href="#&#x4E3B;&#x673A;&#x6E05;&#x5355;---inventory">&#x4E3B;&#x673A;&#x6E05;&#x5355; - Inventory</a></strong></p>
</li>
<li><p><strong><a href="&#x914D;&#x7F6E;&#x6587;&#x4EF6;---ansible.cfg">&#x914D;&#x7F6E;&#x6587;&#x4EF6; - ansible.cfg</a></strong></p>
</li>
<li><p><strong><a href="#ansible-&#x7BA1;&#x7406;&#x88AB;&#x63A7;&#x7AEF;&#x7684;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;">Ansible &#x7BA1;&#x7406;&#x88AB;&#x63A7;&#x7AEF;&#x7684;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;</a></strong></p>
<ul>
<li><strong><a href="#&#x6A21;&#x5757;---module">&#x6A21;&#x5757; - Module</a></strong></li>
<li><strong><a href="#ad-hoc-commands">Ad-Hoc Commands</a></strong></li>
<li><strong><a href="#playbooks---xxxyml">Playbooks - xxx.yml</a></strong></li>
<li><strong><a href="">Role</a></strong></li>
</ul>
<hr>
</li>
<li><p><strong><a href=""></a></strong></p>
</li>
</ul>
<ul>
<li>Tasks&#xFF1A;&#x4EFB;&#x52A1;&#xFF0C;&#x7531;&#x6A21;&#x677F;&#x5B9A;&#x4E49;&#x7684;&#x64CD;&#x4F5C;&#x5217;&#x8868;</li>
<li>Variables&#xFF1A;&#x53D8;&#x91CF;</li>
<li>Templates&#xFF1A;&#x6A21;&#x677F;&#xFF0C;&#x5373;&#x4F7F;&#x7528;&#x6A21;&#x677F;&#x8BED;&#x6CD5;&#x7684;&#x6587;&#x4EF6;</li>
<li>Handlers&#xFF1A;&#x5904;&#x7406;&#x5668; &#xFF0C;&#x5F53;&#x67D0;&#x6761;&#x4EF6;&#x6EE1;&#x8DB3;&#x65F6;&#xFF0C;&#x89E6;&#x53D1;&#x6267;&#x884C;&#x7684;&#x64CD;&#x4F5C;</li>
<li>Roles&#xFF1A;&#x89D2;&#x8272;</li>
<li>Control node &#xFF1A;&#x5B89;&#x88C5;&#x4E86; Ansible &#x7684;&#x4E3B;&#x673A;</li>
<li>Managed nodes&#xFF1A;Ansible &#x7BA1;&#x7406;&#x7684;&#x7F51;&#x7EDC;&#x8BBE;&#x5907;&#x6216;&#x670D;&#x52A1;&#x5668;</li>
</ul>
<h2 id="ansible-&#x67B6;&#x6784;"><a name="ansible-&#x67B6;&#x6784;" class="plugin-anchor" href="#ansible-&#x67B6;&#x6784;"><i class="fa fa-link" aria-hidden="true"></i></a>Ansible &#x67B6;&#x6784;</h2>
<p><img src="images/Ansible-Architechture.png" alt=""></p>
<ul>
<li>&#x7528;&#x6237;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x7F16;&#x5199; Playbook &#x6216;&#x4F7F;&#x7528; Ad-HOC &#x547D;&#x4EE4;&#x76F4;&#x63A5;&#x64CD;&#x63A7; Ansible&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x516C;&#x6709;&#x3001;&#x79C1;&#x6709;&#x4E91;&#x6216; CMDB(Configuration Management Database) &#x64CD;&#x63A7; Ansible</li>
<li>Ansible &#x7EC4;&#x6210;&#xFF1A;<ul>
<li>Inventory - &#x88AB;&#x7BA1;&#x7406;&#x4E3B;&#x673A;&#x6E05;&#x5355;</li>
<li>APIs - &#x63D0;&#x4F9B; Ansible &#x4E0E;&#x4E91;&#x7AEF;&#x7684;&#x4F20;&#x8F93;&#x670D;&#x52A1;</li>
<li>Plugins</li>
<li>Modules</li>
</ul>
</li>
<li>Ansible &#x53EF;&#x7BA1;&#x7406;&#x5BF9;&#x8C61;&#xFF1A;&#x4E3B;&#x673A;&#x548C;&#x7F51;&#x7EDC;&#x8BBE;&#x5907;</li>
</ul>
<h2 id="&#x4E3B;&#x673A;&#x6E05;&#x5355;---inventory"><a name="&#x4E3B;&#x673A;&#x6E05;&#x5355;---inventory" class="plugin-anchor" href="#&#x4E3B;&#x673A;&#x6E05;&#x5355;---inventory"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E3B;&#x673A;&#x6E05;&#x5355; - Inventory</h2>
<blockquote>
<p>&#x88AB;&#x7BA1;&#x7406;&#x4E3B;&#x673A; ( managed nodes ) &#x7684;&#x6E05;&#x5355;&#xFF0C;inventory &#x4E5F;&#x88AB;&#x79F0;&#x505A;&#x201C;hostfile&#x201D;</p>
</blockquote>
<ul>
<li><p>inventory &#x662F; <code>.ini</code> &#x683C;&#x5F0F;&#x7F16;&#x5199;&#x7684;</p>
</li>
<li><p>&#x9ED8;&#x8BA4;&#x8DEF;&#x5F84;&#xFF1A; <code>/etc/ansible/hosts</code></p>
</li>
<li>&#x6307;&#x5B9A;&#x8DEF;&#x5F84;&#xFF1A;<ul>
<li><code>ansible -i &lt;path&gt;</code> &#x6216; <code>ansible-play -i &lt;path&gt;</code> </li>
<li>&#x8BBE;&#x7F6E; ansible.cfg &#x4E2D; <code>[default]</code> &#x4E0B;&#x7684; <code>inventory</code>  &#x4E3A;&#x6307;&#x5B9A; <code>hosts</code> &#x6587;&#x4EF6;&#x8DEF;&#x5F84;</li>
<li><strong>ansible  &#x652F;&#x6301;&#x591A;&#x4E2A; inventory &#x6587;&#x4EF6;</strong>&#x3002;&#x5148;&#x521B;&#x5EFA;&#x4E00;&#x4E2A; <code>inventory/</code> &#x6587;&#x4EF6;&#x5939;&#xFF0C;&#x7136;&#x540E;&#x5C06; ansible.cfg &#x4E2D;&#x7684; <code>inventory</code> &#x8BBE;&#x7F6E;&#x4E3A;<strong>&#x6587;&#x4EF6;&#x5939;&#x7684;&#x8DEF;&#x5F84;</strong></li>
</ul>
</li>
<li><strong>ansible &#x8FD8;&#x652F;&#x6301;&#x52A8;&#x6001;&#x7684; inventory</strong>&#x3002;&#x53EF;&#x4EE5;&#x7528;&#x81EA;&#x5B9A;&#x4E49;&#x811A;&#x672C;&#x4ECE; CMDB &#x7CFB;&#x7EDF;&#x548C; Zabbix &#x76D1;&#x63A7;&#x7CFB;&#x7EDF;&#x7B49;&#x62C9;&#x53D6;&#x6240;&#x6709;&#x7684;&#x4E3B;&#x673A;&#x4FE1;&#x606F;&#xFF0C;&#x811A;&#x672C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4EFB;&#x4F55;&#x8BED;&#x8A00;&#x7F16;&#x5199;&#xFF0C;&#x4F46;&#x662F;&#x811A;&#x672C;&#x4F7F;&#x7528;&#x53C2;&#x6570;&#x6709;&#x4E00;&#x5B9A;&#x7684;&#x89C4;&#x8303;&#x5E76;&#x4E14;&#x5BF9;&#x811A;&#x672C;&#x6267;&#x884C;&#x7684;&#x7ED3;&#x679C;&#x4E5F;&#x6709;&#x8981;&#x6C42;&#xFF0C;&#x5E94;&#x7528;&#x65F6;&#x53EA;&#x9700;&#x8981;&#x628A; ansible.cfg &#x6587;&#x4EF6;&#x4E2D; inventory &#x7684;&#x503C;&#x6539;&#x6210;&#x4E00;&#x4E2A;<strong>&#x6267;&#x884C;&#x811A;&#x672C;&#x8DEF;&#x5F84;</strong>&#x5373;&#x53EF;</li>
</ul>
<p><strong><code>inventory &#x884C;&#x4E3A;&#x53C2;&#x6570;</code></strong></p>
<table>
<thead>
<tr>
<th style="text-align:center">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:center">&#x53C2;&#x6570;&#x8BF4;&#x660E;</th>
<th style="text-align:center">&#x9ED8;&#x8BA4;&#x503C;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">ansible_ssh_host</td>
<td style="text-align:center">&#x767B;&#x5F55;&#x4E3B;&#x673A;&#x7684;hostname&#x6216;ip</td>
<td style="text-align:center">&#x4E3B;&#x673A;&#x540D;</td>
</tr>
<tr>
<td style="text-align:center">ansible_ssh_port</td>
<td style="text-align:center">ssh &#x76EE;&#x7684;&#x7AEF;&#x53E3;</td>
<td style="text-align:center">22</td>
</tr>
<tr>
<td style="text-align:center">ansible_ssh_user</td>
<td style="text-align:center">ssh &#x767B;&#x5F55;&#x4F7F;&#x7528;&#x7684;&#x7528;&#x6237;&#x540D;</td>
<td style="text-align:center">root</td>
</tr>
<tr>
<td style="text-align:center">ansible_ssh_pass</td>
<td style="text-align:center">ssh &#x8BA4;&#x8BC1;&#x4F7F;&#x7528;&#x7684;&#x5BC6;&#x7801;</td>
<td style="text-align:center">None</td>
</tr>
<tr>
<td style="text-align:center">ansible_sudo</td>
<td style="text-align:center">&#x4E3B;&#x673A;&#x7684;sudo&#x7528;&#x6237;</td>
<td style="text-align:center"></td>
</tr>
<tr>
<td style="text-align:center">ansible_sudo_pass</td>
<td style="text-align:center">&#x4E3B;&#x673A;&#x7684;sudo&#x5BC6;&#x7801;</td>
<td style="text-align:center"></td>
</tr>
<tr>
<td style="text-align:center">ansible_sudo_exe</td>
<td style="text-align:center">&#x4E3B;&#x673A;&#x7684;sudo&#x8DEF;&#x5F84;</td>
<td style="text-align:center"></td>
</tr>
<tr>
<td style="text-align:center">ansible_connection</td>
<td style="text-align:center">&#x8FDE;&#x63A5;&#x4E3B;&#x673A;&#x7684;&#x6A21;&#x5F0F;</td>
<td style="text-align:center">smart</td>
</tr>
<tr>
<td style="text-align:center">ansible_ssh_private_key_file</td>
<td style="text-align:center">ssh &#x8BA4;&#x8BC1;&#x4F7F;&#x7528;&#x7684;&#x79C1;&#x94A5;</td>
<td style="text-align:center">None</td>
</tr>
<tr>
<td style="text-align:center">ansible_shell_type</td>
<td style="text-align:center">&#x4E3B;&#x673A;shell&#x7C7B;&#x578B;</td>
<td style="text-align:center">sh</td>
</tr>
<tr>
<td style="text-align:center">ansible_python_interpreter</td>
<td style="text-align:center">&#x4E3B;&#x673A;python&#x89E3;&#x91CA;&#x5668;&#x8DEF;&#x5F84;</td>
<td style="text-align:center">/usr/bin/python</td>
</tr>
<tr>
<td style="text-align:center">ansible_*_interpreter</td>
<td style="text-align:center">&#x7C7B;&#x4F3C;python&#x89E3;&#x91CA;&#x5668;&#x7684;&#x5176;&#x4ED6;&#x8BED;&#x8A00;&#x7248;</td>
<td style="text-align:center">None</td>
</tr>
</tbody>
</table>
<h4 id="&#x4E3B;&#x673A;&#x53D8;&#x91CF;&#x548C;&#x7FA4;&#x7EC4;&#x53D8;&#x91CF;"><a name="&#x4E3B;&#x673A;&#x53D8;&#x91CF;&#x548C;&#x7FA4;&#x7EC4;&#x53D8;&#x91CF;" class="plugin-anchor" href="#&#x4E3B;&#x673A;&#x53D8;&#x91CF;&#x548C;&#x7FA4;&#x7EC4;&#x53D8;&#x91CF;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E3B;&#x673A;&#x53D8;&#x91CF;&#x548C;&#x7FA4;&#x7EC4;&#x53D8;&#x91CF;</h4>
<ul>
<li>Ansible &#x53D8;&#x91CF;&#x652F;&#x6301;&#x5E03;&#x5C14;&#x578B;&#x3001;&#x5B57;&#x7B26;&#x4E32;&#x3001;&#x5217;&#x8868;&#x548C;&#x5B57;&#x5178;&#xFF0C;&#x4F46;<strong>&#x5728; inventory &#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x53EA;&#x80FD;&#x5C06;&#x53D8;&#x91CF;&#x6307;&#x5B9A;&#x4E3A;&#x5E03;&#x5C14;&#x578B;&#x548C;&#x5B57;&#x7B26;&#x4E32;</strong></li>
<li>&#x4EE5;&#x4E0A;&#x4ECB;&#x7ECD;&#x7684; inventory &#x5185;&#x7F6E;&#x53C2;&#x6570;&#x5176;&#x5B9E;&#x5C31;&#x662F;&#x5177;&#x6709;&#x7279;&#x6B8A;&#x610F;&#x4E49;&#x7684; Ansible &#x53D8;&#x91CF;&#xFF0C;&#x53EF;&#x4EE5;&#x9488;&#x5BF9;&#x4E3B;&#x673A;&#x5B9A;&#x4E49;&#x4EFB;&#x610F;&#x7684;&#x53D8;&#x91CF;&#x540D;&#x5E76;&#x6307;&#x5B9A;&#x76F8;&#x5E94;&#x7684;&#x503C;</li>
</ul>
<p><strong><code>&#x4E3B;&#x673A;&#x53D8;&#x91CF;</code></strong></p>
<pre><code class="lang-ini">192.168.13.12 color=green
192.168.13.14 color=red
</code></pre>
<p><strong><code>&#x7FA4;&#x7EC4;&#x53D8;&#x91CF;</code></strong></p>
<ul>
<li><strong>[<group_name>:vars]</group_name></strong></li>
</ul>
<pre><code class="lang-ini"><span class="hljs-section">[all:var]</span>
<span class="hljs-attr">color</span>=green
</code></pre>
<h4 id="&#x4E3B;&#x673A;&#x53D8;&#x91CF;&#x548C;&#x7FA4;&#x7EC4;&#x53D8;&#x91CF;&#x6587;&#x4EF6;"><a name="&#x4E3B;&#x673A;&#x53D8;&#x91CF;&#x548C;&#x7FA4;&#x7EC4;&#x53D8;&#x91CF;&#x6587;&#x4EF6;" class="plugin-anchor" href="#&#x4E3B;&#x673A;&#x53D8;&#x91CF;&#x548C;&#x7FA4;&#x7EC4;&#x53D8;&#x91CF;&#x6587;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E3B;&#x673A;&#x53D8;&#x91CF;&#x548C;&#x7FA4;&#x7EC4;&#x53D8;&#x91CF;&#x6587;&#x4EF6;</h4>
<ul>
<li>&#x53EF;&#x4EE5;&#x4E3A;&#x6BCF;&#x4E2A;&#x4E3B;&#x673A;&#x548C;&#x7FA4;&#x7EC4;&#x521B;&#x5EFA;&#x72EC;&#x7ACB;&#x7684;&#x53D8;&#x91CF;&#x6587;&#x4EF6;&#xFF08;YAML &#x683C;&#x5F0F;&#xFF09;</li>
<li>&#x4E3B;&#x673A;&#x53D8;&#x91CF;&#x6587;&#x4EF6;&#xFF1A;<code>host_vars</code> &#x76EE;&#x5F55;&#x4E2D;&#x5BFB;&#x627E;</li>
<li>&#x7FA4;&#x7EC4;&#x53D8;&#x91CF;&#x6587;&#x4EF6;&#xFF1A;<code>group_vars</code> &#x76EE;&#x5F55;&#x4E2D;&#x5BFB;&#x627E;</li>
</ul>
<blockquote>
<p> &#x8FD9;&#x4E2A;&#x4E24;&#x4E2A;&#x76EE;&#x5F55;&#x548C; playbook &#x548C; inventory &#x6587;&#x4EF6;&#x5E73;&#x7EA7;</p>
</blockquote>
<p><strong>&#x952E;&#x503C;&#x683C;&#x5F0F; :</strong></p>
<pre><code># playbooks/group_vars/production
db_primary_host: prod.db.com
db_primary_port: 5432
db_replica_host: rep.db.com
db_name: mydb
db_user: root
db_pass: 123456

# &#x8BBF;&#x95EE;&#x65B9;&#x6CD5;:
{{ db_primary_host }}
</code></pre><p><strong>&#x5B57;&#x5178;&#x683C;&#x5F0F; :</strong></p>
<pre><code># playbooks/group_vars/production
db:
    user: root
    password: 123456
    name: mydb
    primary:
        host: primary.db.com
        port: 5432
    replica:
        host: replica.db.com
        port: 5432
rabbitmq:
    host: rabbit.example.com
    port: 6379

# &#x8BBF;&#x95EE;&#x65B9;&#x6CD5;
{{ db.primary.host }}
</code></pre><h4 id="&#x52A8;&#x6001;-inventory"><a name="&#x52A8;&#x6001;-inventory" class="plugin-anchor" href="#&#x52A8;&#x6001;-inventory"><i class="fa fa-link" aria-hidden="true"></i></a>&#x52A8;&#x6001; inventory</h4>
<ul>
<li>&#x5982;&#x679C; inventory &#x6587;&#x4EF6;&#x88AB;&#x6807;&#x8BB0;&#x4E3A;&#x53EF;&#x6267;&#x884C;&#xFF0C;&#x5219; Ansible &#x4F1A;&#x5047;&#x8BBE;&#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x52A8;&#x6001;&#x7684; inventory &#x811A;&#x672C;&#x5E76;&#x4E14;&#x6267;&#x884C;&#x5B83;&#x800C;&#x4E0D;&#x662F;&#x8BFB;&#x53D6;&#x5B83;&#x7684;&#x5185;&#x5BB9; - <code>chmod +x &#x6587;&#x4EF6;&#x540D;</code></li>
<li>&#x52A8;&#x6001; inventory &#x811A;&#x672C;&#x5FC5;&#x987B;&#x652F;&#x6301;&#x4E24;&#x4E2A;&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;&#xFF1A;<ul>
<li><code>--host=&lt;hostname&gt;</code> - &#x5217;&#x51FA;&#x4E3B;&#x673A;&#x7684;&#x8BE6;&#x7EC6;&#x4FE1;&#x606F;</li>
<li><code>--list</code> - &#x5217;&#x51FA;&#x7FA4;&#x7EC4;</li>
</ul>
</li>
</ul>
<h4 id="ansiblecfg-&#x8BBE;&#x7F6E;-inventory-&#x884C;&#x4E3A;&#x53C2;&#x6570;&#x9ED8;&#x8BA4;&#x503C;"><a name="ansiblecfg-&#x8BBE;&#x7F6E;-inventory-&#x884C;&#x4E3A;&#x53C2;&#x6570;&#x9ED8;&#x8BA4;&#x503C;" class="plugin-anchor" href="#ansiblecfg-&#x8BBE;&#x7F6E;-inventory-&#x884C;&#x4E3A;&#x53C2;&#x6570;&#x9ED8;&#x8BA4;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>ansible.cfg &#x8BBE;&#x7F6E; Inventory &#x884C;&#x4E3A;&#x53C2;&#x6570;&#x9ED8;&#x8BA4;&#x503C;</h4>
<p>&#x53EF;&#x4EE5;&#x5728; <code>[defaults]</code> &#x4E2D;&#x6539;&#x53D8;&#x4E00;&#x4E9B;&#x884C;&#x4E3A;&#x53C2;&#x6570;&#x7684;&#x9ED8;&#x8BA4;&#x503C;:</p>
<table>
<thead>
<tr>
<th style="text-align:left">inventory &#x884C;&#x4E3A;&#x53C2;&#x6570;</th>
<th style="text-align:left">ansible.cfg &#x9009;&#x9879;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">ansible_ssh_port</td>
<td style="text-align:left">remote_port</td>
</tr>
<tr>
<td style="text-align:left">ansible_ssh_user</td>
<td style="text-align:left">remote_user</td>
</tr>
<tr>
<td style="text-align:left">ansible_ssh_private_key_file</td>
<td style="text-align:left">private_key_file</td>
</tr>
<tr>
<td style="text-align:left">ansible_shell_type, shell &#x7684;&#x540D;&#x79F0;</td>
<td style="text-align:left">executable, shell &#x7684;&#x7EDD;&#x5BF9;&#x8DEF;&#x5F84;</td>
</tr>
</tbody>
</table>
<h4 id="&#x9759;&#x6001;-inventory-&#x4E0E;-&#x52A8;&#x6001;-inventory-&#x7ED3;&#x5408;&#x4F7F;&#x7528;"><a name="&#x9759;&#x6001;-inventory-&#x4E0E;-&#x52A8;&#x6001;-inventory-&#x7ED3;&#x5408;&#x4F7F;&#x7528;" class="plugin-anchor" href="#&#x9759;&#x6001;-inventory-&#x4E0E;-&#x52A8;&#x6001;-inventory-&#x7ED3;&#x5408;&#x4F7F;&#x7528;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x9759;&#x6001; Inventory &#x4E0E; &#x52A8;&#x6001; Inventory &#x7ED3;&#x5408;&#x4F7F;&#x7528;</h4>
<p>1&#x3001;&#x5C06;&#x52A8;&#x6001; inventory &#x548C; &#x9759;&#x6001; inventory &#x653E;&#x5728;&#x540C;&#x4E00;&#x76EE;&#x5F55;&#x4E0B;</p>
<p>2&#x3001;&#x5728; ansible.cfg &#x4E2D;&#x5C06; <code>hostfile</code> &#x7684;&#x503C;, &#x6307;&#x5411;&#x8BE5;&#x76EE;&#x5F55;&#x5373;&#x53EF;</p>
<h2 id="&#x914D;&#x7F6E;&#x6587;&#x4EF6;---ansiblecfg"><a name="&#x914D;&#x7F6E;&#x6587;&#x4EF6;---ansiblecfg" class="plugin-anchor" href="#&#x914D;&#x7F6E;&#x6587;&#x4EF6;---ansiblecfg"><i class="fa fa-link" aria-hidden="true"></i></a>&#x914D;&#x7F6E;&#x6587;&#x4EF6; - <code>ansible.cfg</code></h2>
<p>Playbooks &#x52A0;&#x8F7D;&#x987A;&#x5E8F;&#xFF1A;<strong><code>ANSIBLE_CONFIG</code></strong>  -&gt; <strong><code>./ansible.cfg</code></strong> -&gt; <strong><code>~/.ansible.cfg</code></strong> -&gt; <strong><code>/etc/ansible/ansible.cfg</code></strong></p>
<ul>
<li><strong><code>ANSIBLE_CONFIG</code></strong>&#xFF1A;&#x9996;&#x5148;&#xFF0C;Ansible &#x547D;&#x4EE4;&#x4F1A;&#x5148;&#x68C0;&#x67E5;&#x73AF;&#x5883;&#x53D8;&#x91CF; <code>ANSIBLE_CONFIG</code>&#xFF0C;&#x53CA;&#x8FD9;&#x4E2A;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x5C06;&#x6307;&#x5411;&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</li>
<li><strong><code>./ansible.cfg</code></strong>&#xFF1A;&#x5176;&#x6B21;&#xFF0C;&#x5C06;&#x4F1A;&#x68C0;&#x67E5;&#x5F53;&#x524D;&#x76EE;&#x5F55;&#x4E0B;&#x7684; ansible.cfg &#x914D;&#x7F6E;&#x6587;&#x4EF6;</li>
<li><strong><code>~/.ansible.cfg</code></strong>&#xFF1A;&#x518D;&#x6B21;&#xFF0C;&#x5C06;&#x4F1A;&#x68C0;&#x67E5;&#x5F53;&#x524D;&#x7528;&#x6237; home &#x76EE;&#x5F55;&#x4E0B;&#x7684;<strong><code>~/.ansible.cfg</code></strong> &#x914D;&#x7F6E;&#x6587;&#x4EF6;</li>
<li><strong><code>/etc/ansible/ansible.cfg</code></strong>&#xFF1A;&#x6700;&#x540E;&#xFF0C;&#x5C06;&#x4F1A;&#x68C0;&#x67E5;&#x5728;&#x5B89;&#x88C5; Ansible &#x65F6;&#x81EA;&#x52A8;&#x751F;&#x4EA7;&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</li>
</ul>
<h4 id="&#x5E38;&#x7528;&#x914D;&#x7F6E;&#x9879;"><a name="&#x5E38;&#x7528;&#x914D;&#x7F6E;&#x9879;" class="plugin-anchor" href="#&#x5E38;&#x7528;&#x914D;&#x7F6E;&#x9879;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5E38;&#x7528;&#x914D;&#x7F6E;&#x9879;</h4>
<p><strong><code>[defaults]</code></strong></p>
<table>
<thead>
<tr>
<th style="text-align:center">&#x914D;&#x7F6E;&#x9879;</th>
<th style="text-align:center">&#x8BF4;&#x660E;</th>
<th style="text-align:center">&#x9ED8;&#x8BA4;&#x503C;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">inventory</td>
<td style="text-align:center">ansible inventory&#x6587;&#x4EF6;&#x8DEF;&#x5F84;</td>
<td style="text-align:center">/etc/ansible/hosts</td>
</tr>
<tr>
<td style="text-align:center">library</td>
<td style="text-align:center">ansible&#x6A21;&#x5757;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;</td>
<td style="text-align:center">/usr/share/my_modules/</td>
</tr>
<tr>
<td style="text-align:center">remote_tmp</td>
<td style="text-align:center">ansible&#x8FDC;&#x7A0B;&#x4E3B;&#x673A;&#x811A;&#x672C;&#x4E34;&#x65F6;&#x5B58;&#x653E;&#x76EE;&#x5F55;</td>
<td style="text-align:center">~/.ansible/tmp</td>
</tr>
<tr>
<td style="text-align:center">local_tmp</td>
<td style="text-align:center">ansible&#x7BA1;&#x7406;&#x8282;&#x70B9;&#x811A;&#x672C;&#x4E34;&#x65F6;&#x5B58;&#x653E;&#x76EE;&#x5F55;</td>
<td style="text-align:center">~/.ansible/tmp</td>
</tr>
<tr>
<td style="text-align:center">forks</td>
<td style="text-align:center">ansible&#x6267;&#x884C;&#x5E76;&#x53D1;&#x6570;</td>
<td style="text-align:center">5</td>
</tr>
<tr>
<td style="text-align:center">poll_interval</td>
<td style="text-align:center">ansible&#x5F02;&#x6B65;&#x4EFB;&#x52A1;&#x67E5;&#x8BE2;&#x95F4;&#x9694;</td>
<td style="text-align:center">15</td>
</tr>
<tr>
<td style="text-align:center">sudo_user</td>
<td style="text-align:center">ansible sudo&#x7528;&#x6237;</td>
<td style="text-align:center">root</td>
</tr>
<tr>
<td style="text-align:center">ask_sudo_pass</td>
<td style="text-align:center">&#x8FD0;&#x884C;ansible&#x662F;&#x5426;&#x63D0;&#x793A;&#x8F93;&#x5165;sudo&#x5BC6;&#x7801;</td>
<td style="text-align:center">True</td>
</tr>
<tr>
<td style="text-align:center">ask_pass</td>
<td style="text-align:center">&#x8FD0;&#x884C;ansible&#x662F;&#x5426;&#x63D0;&#x793A;&#x8F93;&#x5165;&#x5BC6;&#x7801;</td>
<td style="text-align:center">True</td>
</tr>
<tr>
<td style="text-align:center">transport</td>
<td style="text-align:center">ansible&#x8FDC;&#x7A0B;&#x4F20;&#x8F93;&#x6A21;&#x5F0F;</td>
<td style="text-align:center">smart</td>
</tr>
<tr>
<td style="text-align:center">remote_port</td>
<td style="text-align:center">&#x8FDC;&#x7A0B;&#x4E3B;&#x673A;SSH&#x7AEF;&#x53E3;</td>
<td style="text-align:center">22</td>
</tr>
<tr>
<td style="text-align:center">module_lang</td>
<td style="text-align:center">ansible&#x6A21;&#x5757;&#x8FD0;&#x884C;&#x9ED8;&#x8BA4;&#x8BED;&#x8A00;&#x73AF;&#x5883;</td>
<td style="text-align:center">C</td>
</tr>
<tr>
<td style="text-align:center">gathering</td>
<td style="text-align:center">facts&#x4FE1;&#x606F;&#x6536;&#x96C6;&#x5F00;&#x5173;&#x5B9A;&#x4E49;</td>
<td style="text-align:center">smart</td>
</tr>
<tr>
<td style="text-align:center">roles_path</td>
<td style="text-align:center">ansible role&#x5B58;&#x653E;&#x8DEF;&#x5F84;</td>
<td style="text-align:center">/etc/ansible/roles</td>
</tr>
<tr>
<td style="text-align:center">timeout</td>
<td style="text-align:center">ansible SSH&#x8FDE;&#x63A5;&#x8D85;&#x65F6;&#x65F6;&#x95F4;</td>
<td style="text-align:center">10</td>
</tr>
<tr>
<td style="text-align:center">remote_user</td>
<td style="text-align:center">ansible&#x8FDC;&#x7A0B;&#x8BA4;&#x8BC1;&#x7528;&#x6237;</td>
<td style="text-align:center">root</td>
</tr>
<tr>
<td style="text-align:center">log_path</td>
<td style="text-align:center">ansible&#x65E5;&#x5FD7;&#x8BB0;&#x5F55;&#x6587;&#x4EF6;</td>
<td style="text-align:center">/var/log/ansible.log</td>
</tr>
<tr>
<td style="text-align:center">module_name</td>
<td style="text-align:center">ansible&#x9ED8;&#x8BA4;&#x6267;&#x884C;&#x6A21;&#x5757;</td>
<td style="text-align:center">command</td>
</tr>
<tr>
<td style="text-align:center">executable</td>
<td style="text-align:center">ansible&#x547D;&#x4EE4;&#x6267;&#x884C;shell</td>
<td style="text-align:center">/bin/sh</td>
</tr>
<tr>
<td style="text-align:center">hash_behaviour</td>
<td style="text-align:center">ansible&#x4E3B;&#x673A;&#x53D8;&#x91CF;&#x91CD;&#x590D;&#x5904;&#x7406;&#x65B9;&#x5F0F;</td>
<td style="text-align:center">replace</td>
</tr>
<tr>
<td style="text-align:center">private_role_vars</td>
<td style="text-align:center">&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x89D2;&#x8272;&#x4E2D;&#x7684;&#x53D8;&#x91CF;&#x5C06;&#x5728;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x8303;&#x56F4;&#x4E2D;&#x53EF;&#x89C1;&#x3002; &#x4E3A;&#x4E86;&#x9632;&#x6B62;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#xFF0C;&#x53EF;&#x4EE5;&#x542F;&#x7528;&#x4EE5;&#x4E0B;&#x9009;&#x9879;&#xFF0C;&#x53EA;&#x6709;tasks&#x7684;&#x4EFB;&#x52A1;&#x548C;handlers&#x5F97;&#x4EFB;&#x52A1;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x89D2;&#x8272;&#x53D8;&#x91CF;</td>
<td style="text-align:center">yes</td>
</tr>
<tr>
<td style="text-align:center">vault_password_file</td>
<td style="text-align:center">&#x6307;&#x5B9A;vault&#x5BC6;&#x7801;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;</td>
<td style="text-align:center">&#x65E0;</td>
</tr>
<tr>
<td style="text-align:center">ansible_managed</td>
<td style="text-align:center">&#x5B9A;&#x4E49;&#x7684;&#x4E00;&#x4E2A;Jinja2&#x53D8;&#x91CF;&#xFF0C;&#x53EF;&#x4EE5;&#x63D2;&#x5165;&#x5230;Ansible&#x914D;&#x7F6E;&#x6A21;&#x7248;&#x7CFB;&#x7EDF;&#x751F;&#x6210;&#x7684;&#x6587;&#x4EF6;&#x4E2D;</td>
<td style="text-align:center">Ansible managed</td>
</tr>
<tr>
<td style="text-align:center">display_skipped_hosts</td>
<td style="text-align:center">&#x5F00;&#x542F;&#x663E;&#x793A;&#x8DF3;&#x8FC7;&#x7684;&#x4E3B;&#x673A;</td>
<td style="text-align:center">True</td>
</tr>
<tr>
<td style="text-align:center">error_on_undefined_vars</td>
<td style="text-align:center">&#x5F00;&#x542F;&#x9519;&#x8BEF;&#xFF0C;&#x6216;&#x8005;&#x6CA1;&#x6709;&#x5B9A;&#x4E49;&#x7684;&#x53D8;&#x91CF;</td>
<td style="text-align:center">False</td>
</tr>
<tr>
<td style="text-align:center">action_plugins</td>
<td style="text-align:center">ansible action&#x63D2;&#x4EF6;&#x8DEF;&#x5F84;</td>
<td style="text-align:center">&#x65E0;</td>
</tr>
<tr>
<td style="text-align:center">cache_plugins</td>
<td style="text-align:center">ansible cache&#x63D2;&#x4EF6;&#x8DEF;&#x5F84;</td>
<td style="text-align:center">&#x65E0;</td>
</tr>
<tr>
<td style="text-align:center">callback_plugins</td>
<td style="text-align:center">ansible callback&#x63D2;&#x4EF6;&#x8DEF;&#x5F84;</td>
<td style="text-align:center">&#x65E0;</td>
</tr>
<tr>
<td style="text-align:center">connection_plugins</td>
<td style="text-align:center">ansible connection&#x63D2;&#x4EF6;&#x8DEF;&#x5F84;</td>
<td style="text-align:center">&#x65E0;</td>
</tr>
<tr>
<td style="text-align:center">lookup_plugins</td>
<td style="text-align:center">ansible lookup&#x63D2;&#x4EF6;&#x8DEF;&#x5F84;</td>
<td style="text-align:center">&#x65E0;</td>
</tr>
<tr>
<td style="text-align:center">inventory_plugins</td>
<td style="text-align:center">ansible inventory&#x63D2;&#x4EF6;&#x8DEF;&#x5F84;</td>
<td style="text-align:center">&#x65E0;</td>
</tr>
<tr>
<td style="text-align:center">vars_plugins</td>
<td style="text-align:center">ansible vars&#x63D2;&#x4EF6;&#x8DEF;&#x5F84;</td>
<td style="text-align:center">&#x65E0;</td>
</tr>
<tr>
<td style="text-align:center">filter_plugins</td>
<td style="text-align:center">ansible filter&#x63D2;&#x4EF6;&#x8DEF;&#x5F84;</td>
<td style="text-align:center">&#x65E0;</td>
</tr>
<tr>
<td style="text-align:center">terminal_plugins</td>
<td style="text-align:center">ansible terminal&#x63D2;&#x4EF6;&#x8DEF;&#x5F84;</td>
<td style="text-align:center">&#x65E0;</td>
</tr>
<tr>
<td style="text-align:center">strategy_plugins</td>
<td style="text-align:center">ansible strategy&#x63D2;&#x4EF6;&#x8DEF;&#x5F84;</td>
<td style="text-align:center">&#x65E0;</td>
</tr>
<tr>
<td style="text-align:center">fact_caching</td>
<td style="text-align:center">&#x5B9A;&#x4E49;ansible facts&#x7F13;&#x5B58;&#x65B9;&#x5F0F;</td>
<td style="text-align:center">memory</td>
</tr>
<tr>
<td style="text-align:center">fact_caching_connection</td>
<td style="text-align:center">&#x5B9A;&#x4E49;ansible facts&#x7F13;&#x5B58;&#x8DEF;&#x5F84;</td>
<td style="text-align:center">&#x65E0;</td>
</tr>
</tbody>
</table>
<p><strong>privilege_escalation - &#x6743;&#x9650;&#x5347;&#x7EA7;</strong></p>
<table>
<thead>
<tr>
<th style="text-align:center">&#x914D;&#x7F6E;&#x9879;</th>
<th style="text-align:center">&#x8BF4;&#x660E;</th>
<th style="text-align:center">&#x9ED8;&#x8BA4;&#x503C;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">become</td>
<td style="text-align:center">&#x662F;&#x5426;&#x5F00;&#x542F;become&#x6A21;&#x5F0F;</td>
<td style="text-align:center">True</td>
</tr>
<tr>
<td style="text-align:center">become_method</td>
<td style="text-align:center">&#x5B9A;&#x4E49;become&#x65B9;&#x5F0F;</td>
<td style="text-align:center">sudo</td>
</tr>
<tr>
<td style="text-align:center">become_user</td>
<td style="text-align:center">&#x5B9A;&#x4E49;become&#x65B9;&#x5F0F;</td>
<td style="text-align:center">root</td>
</tr>
<tr>
<td style="text-align:center">become_ask_pass</td>
<td style="text-align:center">&#x662F;&#x5426;&#x5B9A;&#x4E49;become&#x63D0;&#x793A;&#x5BC6;&#x7801;</td>
<td style="text-align:center">False</td>
</tr>
</tbody>
</table>
<h2 id="ansible-&#x7BA1;&#x7406;&#x88AB;&#x63A7;&#x7AEF;&#x7684;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;"><a name="ansible-&#x7BA1;&#x7406;&#x88AB;&#x63A7;&#x7AEF;&#x7684;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;" class="plugin-anchor" href="#ansible-&#x7BA1;&#x7406;&#x88AB;&#x63A7;&#x7AEF;&#x7684;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a>Ansible &#x7BA1;&#x7406;&#x88AB;&#x63A7;&#x7AEF;&#x7684;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;</h2>
<div align="center">
<img src="images/ansible&#x7684;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;.png">
</div>

<blockquote>
<p> <strong>Ad-hoc &#x548C; playbook &#x53EF;&#x4EE5;&#x770B;&#x6210;&#x662F; Linux &#x4E0B;&#x7684;&#x547D;&#x4EE4;&#x548C; shell &#x811A;&#x672C;&#x4E4B;&#x95F4;&#x7684;&#x5173;&#x7CFB;</strong></p>
</blockquote>
<h3 id="&#x6A21;&#x5757;---module"><a name="&#x6A21;&#x5757;---module" class="plugin-anchor" href="#&#x6A21;&#x5757;---module"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6A21;&#x5757; - Module</h3>
<ul>
<li>Bash &#x4E2D;&#x7684;&#x5E38;&#x7528;&#x547D;&#x4EE4; <code>cd</code>&#x3001;<code>yum</code>&#x3001;<code>apt</code> &#x7B49;&#xFF0C;&#x5728; Ansible &#x4E2D;&#x5C31;&#x5BF9;&#x5E94;&#x4E8E;&#x6A21;&#x5757;&#xFF0C;&#x6240;&#x4EE5;&#x6A21;&#x5757;&#x53EF;&#x89C6;&#x4E3A; Ansible &#x7684; &#x201C;&#x547D;&#x4EE4;&#x201D;</li>
<li>Bash &#x4E2D;&#x8C03;&#x7528;&#x547D;&#x4EE4;&#x65F6;&#x53EF;&#x4EE5;&#x8DDF;&#x4E0D;&#x540C;&#x7684;&#x53C2;&#x6570;&#xFF0C;&#x6BCF;&#x4E2A;&#x547D;&#x4EE4;&#x7684;&#x53C2;&#x6570;&#x90FD;&#x662F;&#x8BE5;&#x547D;&#x4EE4;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#xFF1B;&#x540C;&#x6837;&#xFF0C;Ansible &#x4E2D;&#x8C03;&#x7528; module &#x4E5F;&#x53EF;&#x4EE5;&#x8DDF;&#x4E0D;&#x540C;&#x7684;&#x53C2;&#x6570;&#xFF0C;&#x6BCF;&#x4E2A;module &#x7684;&#x53C2;&#x6570;&#x4E5F;&#x90FD;&#x662F;&#x7531; module &#x81EA;&#x5B9A;&#x4E49;&#x7684;</li>
<li>Ansible &#x81EA;&#x5E26;&#x7684;&#x6A21;&#x5757;&#x90FD;&#x662F;&#x7528; Python &#x7F16;&#x5199;&#x7684;&#xFF0C;&#x4F46;&#x5B9E;&#x9645;&#x4E0A;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4EFB;&#x4F55;&#x8BED;&#x8A00;&#x7F16;&#x5199;&#x6A21;&#x5757;</li>
<li>Ansible &#x63D0;&#x4F9B;&#x4E00;&#x4E9B;&#x5E38;&#x7528;&#x529F;&#x80FD;&#x7684; Module&#xFF0C;&#x540C;&#x65F6; Ansible &#x4E5F;&#x63D0;&#x4F9B; API&#xFF0C;&#x8BA9;&#x7528;&#x6237;&#x53EF;&#x4EE5;&#x81EA;&#x5DF1;&#x5199; Module&#xFF0C;&#x4F7F;&#x7528;&#x7684;&#x7F16;&#x7A0B;&#x8BED;&#x8A00;&#x662F; Python</li>
</ul>
<h4 id="&#x67E5;&#x770B;-module-&#x7528;&#x6CD5;"><a name="&#x67E5;&#x770B;-module-&#x7528;&#x6CD5;" class="plugin-anchor" href="#&#x67E5;&#x770B;-module-&#x7528;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x67E5;&#x770B; module &#x7528;&#x6CD5;</h4>
<ul>
<li><strong><code>ansible-doc &lt;module_name&gt;</code></strong></li>
</ul>
<h4 id="&#x547D;&#x4EE4;&#x884C;&#x4E2D;&#x4F7F;&#x7528;-module"><a name="&#x547D;&#x4EE4;&#x884C;&#x4E2D;&#x4F7F;&#x7528;-module" class="plugin-anchor" href="#&#x547D;&#x4EE4;&#x884C;&#x4E2D;&#x4F7F;&#x7528;-module"><i class="fa fa-link" aria-hidden="true"></i></a>&#x547D;&#x4EE4;&#x884C;&#x4E2D;&#x4F7F;&#x7528; module</h4>
<ul>
<li><strong><code>ansible &lt;host-pattern&gt; -m &lt;module_name&gt; -a &apos;&lt;module_args&gt;&apos;</code></strong> </li>
</ul>
<h4 id="playbook-&#x811A;&#x672C;&#x4E2D;&#x4F7F;&#x7528;-module"><a name="playbook-&#x811A;&#x672C;&#x4E2D;&#x4F7F;&#x7528;-module" class="plugin-anchor" href="#playbook-&#x811A;&#x672C;&#x4E2D;&#x4F7F;&#x7528;-module"><i class="fa fa-link" aria-hidden="true"></i></a>Playbook &#x811A;&#x672C;&#x4E2D;&#x4F7F;&#x7528; module</h4>
<ul>
<li>tasks &#x4E2D;&#x7684;&#x6BCF;&#x4E00;&#x4E2A; action &#x90FD;&#x662F;&#x5BF9;&#x5E94; module &#x7684;&#x4E00;&#x6B21;&#x8C03;&#x7528;</li>
<li><strong><code>&lt;module_name&gt;: &lt;module_args&gt;</code></strong></li>
</ul>
<pre><code class="lang-yaml"><span class="hljs-attr">tasks:</span>
<span class="hljs-attr">  - name:</span> ensure apache is at the latest version
<span class="hljs-attr">     yum:</span> pkg=httpd state=latest
</code></pre>
<h3 id="ad-hoc-commands"><a name="ad-hoc-commands" class="plugin-anchor" href="#ad-hoc-commands"><i class="fa fa-link" aria-hidden="true"></i></a>Ad-Hoc Commands</h3>
<h4 id="ad-hoc-&#x6267;&#x884C;&#x8FC7;&#x7A0B;"><a name="ad-hoc-&#x6267;&#x884C;&#x8FC7;&#x7A0B;" class="plugin-anchor" href="#ad-hoc-&#x6267;&#x884C;&#x8FC7;&#x7A0B;"><i class="fa fa-link" aria-hidden="true"></i></a>Ad-Hoc &#x6267;&#x884C;&#x8FC7;&#x7A0B;</h4>
<blockquote>
<ul>
<li>&#x52A0; <code>-vvv</code> &#x53EF;&#x67E5;&#x770B;&#x6267;&#x884C;&#x8FC7;&#x7A0B;</li>
</ul>
</blockquote>
<p>1&#x3001;&#x52A0;&#x8F7D;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF0C;&#x9ED8;&#x8BA4;&#x662F; <code>/etc/ansible/ansible.cfg</code></p>
<p>2&#x3001;&#x52A0;&#x8F7D;&#x6A21;&#x5757;&#x6587;&#x4EF6;</p>
<p>3&#x3001; &#x5C06; Ad-Hoc &#x751F;&#x6210;&#x5BF9;&#x5E94;&#x7684;&#x4E34;&#x65F6; py &#x6587;&#x4EF6;&#xFF0C;&#x5E76;&#x5C06;&#x6587;&#x4EF6;&#x4F20;&#x8F93;&#x5230;&#x88AB;&#x63A7;&#x4E3B;&#x673A;&#x7684;&#x5BF9;&#x5E94;&#x7528;&#x6237; <code>~/.ansible/tmp/ansible-tmp-xxx/xxx.py</code></p>
<p>4&#x3001;&#x88AB;&#x63A7;&#x4E3B;&#x673A; py &#x6587;&#x4EF6;&#x52A0;&#x6267;&#x884C;&#x6743;&#x9650;&#xFF08; +x &#xFF09;</p>
<p>5&#x3001;&#x6267;&#x884C; py &#x6587;&#x4EF6;&#x5E76;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;</p>
<p>6&#x3001;&#x5220;&#x9664;&#x672C;&#x5730;&#x548C;&#x88AB;&#x63A7;&#x4E3B;&#x673A;&#x4E0A;&#x7684;&#x4E34;&#x65F6; py &#x6587;&#x4EF6;&#xFF0C;<code>sleep 0</code> &#x9000;&#x51FA;</p>
<h3 id="playbooks---xxxyml"><a name="playbooks---xxxyml" class="plugin-anchor" href="#playbooks---xxxyml"><i class="fa fa-link" aria-hidden="true"></i></a>Playbooks - <code>xxx.yml</code></h3>
<p><img src="images/playbook.png" alt=""></p>
<blockquote>
<ul>
<li>Playbooks contain plays</li>
<li>Plays contain tasks</li>
<li>Tasks call modules, tasks run sequentially</li>
<li>Handlers are triggered by tasks</li>
</ul>
</blockquote>
<ul>
<li>&#x4E00;&#x4E2A; Playbook &#x53EF;&#x4EE5;&#x5305;&#x542B;&#x591A;&#x4E2A; Play</li>
<li><p>&#x4E00;&#x4E2A; Play &#x4E00;&#x5B9A;&#x5305;&#x542B;&#x4E00;&#x4E2A; hosts &#x548C; tasks&#xFF0C;&#x4E5F;&#x53EF;&#x80FD;&#x6709; variables&#x3001;roles&#x3001;handlers &#x7B49;</p>
</li>
<li><p>Playbooks&#x8BED;&#x6CD5; - YAML</p>
</li>
<li>playbook &#x5176;&#x5B9E;&#x5C31;&#x662F;&#x4E00;&#x4E2A;<strong>&#x5B57;&#x5178;&#x5217;&#x8868;</strong>&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x4E00;&#x4E2A; playbook &#x5C31;&#x662F;&#x4E00;&#x4E2A; play &#x5217;&#x8868;</li>
</ul>
<h3 id="handlers"><a name="handlers" class="plugin-anchor" href="#handlers"><i class="fa fa-link" aria-hidden="true"></i></a>Handlers</h3>
<h3 id="roles"><a name="roles" class="plugin-anchor" href="#roles"><i class="fa fa-link" aria-hidden="true"></i></a>Roles</h3>
<h3 id="facts"><a name="facts" class="plugin-anchor" href="#facts"><i class="fa fa-link" aria-hidden="true"></i></a>Facts</h3>
<footer class="page-footer-ex"> <span class="page-footer-ex-copyright"> <a href="https://github.com/Xiechengqi" target="_blank">Xiechengqi</a> </span> &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <span class="page-footer-ex-footer-update"> <strong>&#x6700;&#x65B0;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;</strong> 2020-01-10 16:05:52 </span> </footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="Ansible必知单词.html" class="navigation navigation-prev " aria-label="Previous page: Ansible 常用单词">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="Ansible常用模板.html" class="navigation navigation-next " aria-label="Next page: Ansible常用模板.md">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Ansible 学习笔记","level":"1.8.3","depth":2,"next":{"title":"Ansible常用模板.md","level":"1.8.4","depth":2,"path":"Ansible/Ansible常用模板.md","ref":"Ansible/Ansible常用模板.md","articles":[]},"previous":{"title":"Ansible 常用单词","level":"1.8.2","depth":2,"path":"Ansible/Ansible必知单词.md","ref":"Ansible/Ansible必知单词.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-lunr","-search","-livereload","-sharing","expandable-chapters","popup","pageview-count","code","back-to-top-button","hide-element","github-buttons","github","splitter","search-pro","anchors","page-footer-ex","advanced-emoji","sharing-plus"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"github":{"url":"https://github.com/Xiechengqi/LearningNotes"},"page-footer-ex":{"copyright":"[Xiechengqi](https://github.com/Xiechengqi)","markdown":true,"update_format":"YYYY-MM-DD HH:mm:ss","update_label":"<strong>最新修订时间：</strong>"},"splitter":{},"search-pro":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"popup":{},"code":{"copyButtons":true},"hide-element":{"elements":[".gitbook-link"]},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"back-to-top-button":{},"pageview-count":{},"github-buttons":{"buttons":[{"user":"Xiechengqi","repo":"LearningNotes","type":"star","size":"small","count":true}]},"advanced-emoji":{"embedEmojis":false},"sharing":{"qq":false,"douban":false,"facebook":false,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"expandable-chapters":{}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"日常学习笔记","language":"zh-hans","gitbook":"*","description":"日常学习笔记"},"file":{"path":"Ansible/Ansible学习.md","mtime":"2020-01-10T08:05:52.878Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-03-28T02:57:41.582Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

